<?php

class User extends AppModel
{

    var $name = 'User';
    var $displayField = 'firstname';
    var $actsAs = array('Tags.Taggable');

    /*virtual field below is making problems with the searching of users based on city in jqgrid*/
    /*var $virtualFields = array(
        'name' => "CONCAT(User.firstname, ' ', User.lastname)"
    );*/
    var $order = array('User.firstname' => 'ASC');
    var $validate = array(
        'firstname' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                'message' => 'Please enter firstname',
                'allowEmpty' => false,
                'required' => true
            ),
            'minLength' => array(
                'rule' => array('minLength', 2),
                'message' => 'First name should be atleast 2 characters long'
            )
        ),
        'lastname' => array(
            'minLength' => array(
                'rule' => array('minLength', 2),
                'allowEmpty' => true,
                'message' => 'Last name should be atleast 2 characters long'
            )
        ),
        'city_id' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                'message' => 'Select city',
                'allowEmpty' => false,
                'required' => true
            ),
        ),
        'state_id' => array(
            'alphaNumeric' => array(
                'rule' => 'alphaNumeric',
                'allowEmpty' => false,
                'required' => true,
                'message' => 'Please choose your state'
            )
        )
    );
    //The Associations below have been created with all possible keys, those that are not needed can be removed
    var $belongsTo = array(
        'City' => array(
            'className' => 'City',
            'foreignKey' => 'city_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Leadsource' => array(
            'className' => 'Leadsource',
            'foreignKey' => 'leadsource_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Location' => array(
            'className' => 'Location',
            'foreignKey' => 'location_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Awarenesssource' => array(
            'className' => 'Awarenesssource',
            'foreignKey' => 'awarenesssource_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Employee' => array(
            'className' => 'Employee',
            'foreignKey' => 'employee_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );
    var $hasMany = array(
        'Potential' => array(
            'className' => 'Potential',
            'foreignKey' => 'user_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        ),
        'Useractivity' => array(
            'className' => 'Useractivity',
            'foreignKey' => 'user_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        )
    );

}
?>